<template>
  <div class="page-at">
    <video
      ref="player"
      class="page-at"
      controls
    />
  </div>
</template>

<script>
import flvjs from "flv.js";
import { getUrl } from './ApiHaikang'

export default {
    name: "StudyHaikangWeb",
    data () {
        return {
            player: null
        }
    },
    mounted() {
        let video = this.$refs.player
        if (!flvjs.isSupported() || !video) {
            return
        }
        getUrl().then(url => {
            this.player = flvjs.createPlayer({
                type: "flv",
                isLive: true,
                // url: `ws://localhost:8888/rtsp/123/?url=${url}`
                url: `http://121.40.237.31:38001/live?port=31935&app=hls&stream=${url}`
            });
            console.log(this.player)
            this.player.attachMediaElement(video);
            try {
                this.player.load();
                this.player.play();
            } catch (error) {
                console.log(error);
            }
        })
    }
}
</script>

<style scoped>

</style>